package com.hades.example.java.refactoring.after.c10.c10_15_replace_exception_with_test;

import java.util.Stack;

public class ResourcePool {
    Stack<Resource> _available = new Stack<>();
    Stack<Resource> _allocated = new Stack<>();

    Resource getResource() {
        Resource result;
        if (_available.isEmpty()) {
            result = new Resource("new created");
        } else {
            result = _available.pop();
        }
        _allocated.push(result);
        return result;
    }
}